#ifndef KWDB_SDK_POINT_H
#define KWDB_SDK_POINT_H

#include <string>
#include <map>
#include <chrono>

namespace kwdb {

/**
 * @brief Represents a data point in KWDB time-series format
 *
 * A point consists of:
 * - measurement: table/measurement name
 * - tags: key-value pairs for indexing (string->string)
 * - fields: key-value pairs for data (string->double)
 * - timestamp: time point
 */
class Point {
public:
    Point() : timestamp_(std::chrono::system_clock::now()) {}
    explicit Point(const std::string& measurement)
        : measurement_(measurement),
          timestamp_(std::chrono::system_clock::now()) {}

    // Builder methods
    Point& measurement(const std::string& m) {
        measurement_ = m;
        return *this;
    }

    Point& add_tag(const std::string& key, const std::string& value) {
        tags_[key] = value;
        return *this;
    }

    Point& add_field(const std::string& key, double value) {
        fields_[key] = value;
        return *this;
    }

    Point& timestamp(const std::chrono::system_clock::time_point& ts) {
        timestamp_ = ts;
        return *this;
    }

    // Auto set timestamp to now
    Point& timestamp_now() {
        timestamp_ = std::chrono::system_clock::now();
        return *this;
    }

    // Getters
    const std::string& get_measurement() const { return measurement_; }
    const std::map<std::string, std::string>& get_tags() const { return tags_; }
    const std::map<std::string, double>& get_fields() const { return fields_; }
    const std::chrono::system_clock::time_point& get_timestamp() const { return timestamp_; }

private:
    std::string measurement_;
    std::map<std::string, std::string> tags_;
    std::map<std::string, double> fields_;
    std::chrono::system_clock::time_point timestamp_;
};

} // namespace kwdb

#endif // KWDB_SDK_POINT_H